#ifndef __KSERVICE_CONSOLE_H_
#define __KSERVICE_CONSOLE_H_

#include "typedef.h"

struct command {
    int (*func)(int argc, char* argv[]);
    const char *name;
    const char *help;
};

#define SHELL_SECTION \
    __attribute__((section("shell")))

#define DEFINE_STATIC_CMD(f, h)              \
    struct command cmd_##f SHELL_SECTION = { \
        .func = f,                           \
        .name = (const char *)#f,            \
        .help = (const char *)h};

void terminal_init();

/**
 * @brief construct argc argv style params from comand line
 *
 * @param cmd the command string from shell input
 * @param limit the maximum argv can be saved
 * @param argc the address to save arg count
 * @param argv the char* array to save arg values
 * @note  caller must ensure there has enough space to save string address
 */
void construct_param(char *cmd, int limit, int *argc, char **argv);

#endif //__KSERVICE_CONSOLE_H_